import 'package:flutter/material.dart';

import '../../config/public_text.dart';
import '../text_field/border_text_field.dart';
import 'horizontal_item.dart';
import 'vertical_item.dart';

/// FileName text_view_item
///
/// @Author lax
/// @Date 2023/3/30
///
/// @Description

class TextViewItem extends VerticalItem {
  TextViewItem({
    super.key,
    super.title,
    String? value,
    String? hintText,
    super.enable = true,
    super.required = false,
    super.padding,
    super.titleStyle,
    super.valueStyle,
    super.unableTitleStyle,
    super.unableValueStyle,
    super.hintTextStyle,
    super.topWidget,
    super.bottomWidget,
    ValueChanged<String>? onChanged,
    int? maxLength = 500, // 最大字符数 默认500 null不限制
    int? maxLines = 5,
    int minLines = 5,
    TextStyle? counterStyle,
    TextInputType? keyboardType,
    Color? color,
    Color? borderColor,
    bool unableShowTextView = false, // 不可编辑也显示TextView
  }) : super(
          hintText: hintText ?? PublicText.pleaseInput,
          value: (enable || unableShowTextView) ? value : null,
          titleWidget: (enable || unableShowTextView)
              ? null
              : HorizontalItem(
                  required: required,
                  enable: enable,
                  padding: EdgeInsets.zero,
                  title: title,
                  value: value,
                  titleStyle: titleStyle,
                  valueStyle: valueStyle,
                ),
          valueWidget: (enable || unableShowTextView)
              ? BorderTextField(
                  onChanged: onChanged,
                  text: value,
                  enable: enable,
                  style: enable ? valueStyle : unableValueStyle,
                  hintText: enable ? hintText : '',
                  hintStyle: hintTextStyle,
                  counterStyle: counterStyle,
                  textAlign: TextAlign.left,
                  keyboardType: keyboardType,
                  color: color,
                  borderColor: borderColor,
                  maxLines: maxLines,
                  minLines: minLines,
                  maxLength: enable == true ? maxLength : null,
                )
              : null,
        );
}
